//
//  DetailMonthView.swift
//  StoreProject
//
//  Created by CYC on 2021/9/29.
//

import UIKit

class DetailMonthView: UIView {
    
    var model = MonthModel()

    override init(frame: CGRect) {
        super.init(frame: frame)
        
    }
    
    required init?(coder: NSCoder) {
        fatalError("")
    }
    
    
    // MARK:创建UI
    func creatUIAction(model: MonthModel) {
        
        self.model = model
        self.removeAllSubviews()
        
        
        // 确定这个月第一天是星期几
        let firstDay = model.dayList.first
        let firstIndex = (firstDay?.date.weekday)! - 1

        let BW = CGFloat((self.c_width() - kSpaceSize*2)/7.0)
        
        let lab = UILabel.init(frame: CGRect.init(x: kSpaceSize + BW * CGFloat(firstIndex), y: self.c_height() - 30, width: BW, height: 30))
        lab.textAlignment = .center
        lab.font = kBFont(16)
        lab.text = String.init(format: "%d月", model.month)
        self.addSubview(lab)
        
        // 如果是当前年月份
        if model.year == kTodayCom.year && model.month == kTodayCom.month {
            
            lab.textColor = kMainColor
        } else {
            
            lab.textColor = kLabelColor1
        }
        
        
    }

}
